package com.itboye.hutouben.presenter;

import com.itboye.hutouben.bean.HomeMallBean;
import com.itboye.hutouben.bean.WeiXiuBeans;
import com.itboye.hutouben.interfaces.IHomeRadMall;
import com.itboye.hutouben.responsitory.HomeMallprinsitory;
import com.itboye.hutouben.volley.ICompleteListener;
import com.itboye.hutouben.volley.ResultEntity;

import java.util.Observer;

/**
 * Created by itboye on 2016/12/3.
 */

public class HomeMallPresenter extends BasePresenter implements
        IHomeRadMall<HomeMallBean> {

    /**
     * 道路救援
     */
    public static final String ShopIngMall_success = HomeMallPresenter.class.getName()
            + "_ShopIngMall_success";
    public static final String ShopIngMall_fail = HomeMallPresenter.class.getName()
            + "_ShopIngMall_fail";


    public static final String Repair_success = HomeMallPresenter.class.getName()
            + "_Repair_success";
    public static final String Repair_fail = HomeMallPresenter.class.getName()
            + "_Repair_fail";

    public static final String Driver_success = HomeMallPresenter.class.getName()
            + "_Driver_success";
    public static final String Driver_fail = HomeMallPresenter.class.getName()
            + "_Driver_fail";
    public HomeMallPresenter(Observer observer) {
        super(observer);
    }

    /**
     * 首页道路救援
     * @param uid
     * @param
     *
     */
    @Override
    public void onRadRescus(String uid, String mobile,String address,String detail,String vehicle_type, String area,String images,String lng,String lat) {
        IHomeRadMall<WeiXiuBeans> user = new HomeMallprinsitory(
                new ICompleteListener() {

                    @Override
                    public void success(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(Driver_success);
                        HomeMallPresenter.this.setChanged();
                        HomeMallPresenter.this.notifyObservers(result);
                    }

                    @Override
                    public void failure(ResultEntity result) {
                        result.setEventTag(Tag_Error);
                        result.setEventType(Driver_fail);
                        HomeMallPresenter.this.setChanged();
                        HomeMallPresenter.this.notifyObservers(result);

                    }
                });
        user.onRadRescus(uid, mobile,address,detail,vehicle_type,area,images,lng,lat);
    }

    /**
     * 老司机
     * @param uid
     * @param id
     */
    @Override
    public void onOldDriver(String uid, String id) {
        IHomeRadMall<WeiXiuBeans> user = new HomeMallprinsitory(
                new ICompleteListener() {

                    @Override
                    public void success(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(Driver_success);
                        HomeMallPresenter.this.setChanged();
                        HomeMallPresenter.this.notifyObservers(result);
                    }

                    @Override
                    public void failure(ResultEntity result) {
                        result.setEventTag(Tag_Error);
                        result.setEventType(Driver_fail);
                        HomeMallPresenter.this.setChanged();
                        HomeMallPresenter.this.notifyObservers(result);

                    }
                });
        user.onOldDriver(uid, id);
    }

    @Override
    public void onRepair() {
        IHomeRadMall<WeiXiuBeans> user = new HomeMallprinsitory(
                new ICompleteListener() {

                    @Override
                    public void success(ResultEntity result) {
                        result.setEventTag(Tag_Success);
                        result.setEventType(Repair_success);
                        HomeMallPresenter.this.setChanged();
                        HomeMallPresenter.this.notifyObservers(result);
                    }

                    @Override
                    public void failure(ResultEntity result) {
                        result.setEventTag(Tag_Error);
                        result.setEventType(Repair_fail);
                        HomeMallPresenter.this.setChanged();
                        HomeMallPresenter.this.notifyObservers(result);

                    }
                });
        user.onRepair();
    }
}
